package com.dev.utils.app;

import ohos.agp.components.Image;
import ohos.agp.components.element.PixelMapElement;
import ohos.media.image.PixelMap;

public class ImageViewUtils {

    /**
     * 设置 ImageView Bitmap
     * @param imageView {@link Image}
     * @param bitmap    {@link PixelMap}
     * @param <T>       泛型
     * @return {@link ImageView}
     */
    public static <T extends Image> T setImagePixelMap(
            final T imageView,
            final PixelMap bitmap) {
        if (imageView != null) {
            try {
                imageView.setImageElement(new PixelMapElement(bitmap));
            } catch (Exception e) {
//                LogPrintUtils.eTag(TAG, e, "setImageBitmap");
            }
        }
        return imageView;
    }
}
